<?php

/**
 * Media filter form base class.
 *
 * @package    campus-paris
 * @subpackage filter
 * @author     Supinfo
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseMediaFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'album_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Album'), 'add_empty' => true)),
      'name'     => new sfWidgetFormFilterInput(),
      'type'     => new sfWidgetFormChoice(array('choices' => array('' => '', 'image' => 'image', 'video' => 'video'))),
    ));

    $this->setValidators(array(
      'album_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Album'), 'column' => 'id')),
      'name'     => new sfValidatorPass(array('required' => false)),
      'type'     => new sfValidatorChoice(array('required' => false, 'choices' => array('image' => 'image', 'video' => 'video'))),
    ));

    $this->widgetSchema->setNameFormat('media_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Media';
  }

  public function getFields()
  {
    return array(
      'id'       => 'Number',
      'album_id' => 'ForeignKey',
      'name'     => 'Text',
      'type'     => 'Enum',
    );
  }
}
